<template>
  <view v-if="visible" class="modal-overlay" @click="handleClose">
    <view class="modal-container" @click.stop>
      <!-- 标题栏 -->
      <view class="modal-header">
        <text class="modal-title">检验信息</text>
        <view class="close-btn" @click="handleClose">
          <text class="close-icon">×</text>
        </view>
      </view>

      <!-- 内容区域 -->
      <view class="modal-content">
        <!-- 表格 -->
        <uni-table border stripe emptyText="暂无更多数据">
          <!-- 表头 -->
          <uni-tr>
            <uni-th width="90" align="center">检验项目</uni-th>
            <uni-th width="60" align="center">项目值</uni-th>
            <uni-th width="60" align="center">单位</uni-th>
          </uni-tr>
          <!-- 表格数据 -->
          <uni-tr v-for="(item, index) in testData" :key="index">
            <uni-td align="center">{{ item.name }}</uni-td>
            <uni-td align="center">{{ item.value }}</uni-td>
            <uni-td align="center">{{ item.unit }}</uni-td>
          </uni-tr>
        </uni-table>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: "TestInfoModal",
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    testData: {
      type: Array,
      default: () => [],
      // 数据格式: [{ name: '检验项目', value: '项目值', unit: '单位' }]
    },
  },
  methods: {
    handleClose() {
      this.$emit("close");
    },
  },
};
</script>

<style scoped>
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-container {
  width: 650rpx;
  max-height: 80vh;
  background-color: #ffffff;
  border-radius: 16rpx;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 标题栏 */
.modal-header {
  position: relative;
  padding: 30rpx;
  border-bottom: 1rpx solid #eeeeee;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333333;
}

.close-btn {
  position: absolute;
  top: 20rpx;
  right: 20rpx;
  width: 50rpx;
  height: 50rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.close-icon {
  font-size: 50rpx;
  color: #999999;
  line-height: 1;
}

/* 内容区域 */
.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 30rpx;
  max-height: 70vh;
}

/* 空状态 */
.empty-state {
  padding: 60rpx 0;
  text-align: center;
}

.empty-text {
  font-size: 28rpx;
  color: #999999;
}
</style>
